<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<title>购物车-${setting.name}</title>
		[#include "common/include.ftl"]
		<link rel="styleSheet" href="${base}/resource/css/cart.css">
		<script type="text/javascript" src="${base}/resource/js/common.js"></script>
		<script type="text/javascript" src="${base}/resource/js/cart.js"></script>
        <script src="${base}/resource/js/unslider.min.js"></script>
		<script type="text/javascript">
			/**
			 * 批量收藏
			 */
			function batchCollect(){
				var goodsIds = [];
				var hasError = false;
				var reg = /^[1-9]\d*$/;
				$(".cartItemChecked").each(function(index, domEle) {
					var checkBox = $(domEle);
					if(checkBox.is(':checked')) {
						var goodsId = checkBox.attr('goods-id');
						if(!reg.test(goodsId)) {
							hasError = true;
							return false;
						}
						goodsIds.push(goodsId);
					}
				});
				if(hasError) {
					return;
				}
				if(goodsIds.length == 0) {
					oDialog.prompt('请选择要收藏的商品!');
					return;
				}
				ajax({
					url: base + "/member/addFavorite.jhtml",
					data: {goodsIds: goodsIds},
					showError: true,
					cache: false,
					success: function(data) {
						oDialog.prompt("商品收藏成功!");
					}
				});
			}
		</script>
	</head>
	<body class="customer">
		<div class="top w1">
			[#include "/common/header-top.ftl"/]
			<div class="top-search w">
				<div id="header-logo">
					<a href="${base}/index.jhtml">
						<img src="[@Pic pic=setting.logo/]" style="width: 256px; height: 60px;">
					</a>
				</div>
				<div id="cart-step">
					<div class="step step1"></div>
				</div>
				<div class="clear"></div>
			</div>
		</div>
		<div id="P_cart">
			[#if cart?? && (cart.items?has_content || cart.shopItems?has_content) ]
			[#if cart.items?has_content]
				<table class="cart-main">
                    <tr>
                        <th width="40%">商品名称</th>
                        <th width="8%">商品编号</th>
                        <th width="8%">商品规格</th>
                        <!--<th width="10%">生产厂家</th>-->
                        <th width="8%">单价</th>
                        <th width="10%">数量</th>
                        <th width="8%">小计</th>
                        <th width="10%">操作</th>
                    </tr>
					<form id="buyForm" action="${base}/order/confirm.jhtml" method="post">
						[#list cart.items as cartItem]
							[#assign itemCateCode = cartItem.cateCode]
							<tr class="cart-list-item" cart-item-id = ${cartItem.id}>
								<td>
									<table width="100%" class="cart-name-wrap">
										<tr>
											<td width="10%">
												<input type="checkbox" class="cartItemChecked" goods-id="${cartItem.goodsId}" value="${cartItem.id}" name="cartItemIds" checked=true/>
											</td>
											<td width="15%" class="cart-item-img">
												<a href="${base}/goods/${cartItem.goodsId}.jhtml" title="${cartItem.productName}" target="_blank">
													<img class="lazy" data-original="[@Pic pic=cartItem.image postfix='75x75'/]" postfix="75x75">
												</a>
											</td>
											<td width="50%" class="cart-item-name">
												<a href="${base}/goods/${cartItem.goodsId}.jhtml" target="_blank">
													${cartItem.productName}
												</a>
											</td>
										</tr>
									</table>
								</td>
								<td>${cartItem.productCode}</td>
								<td>${cartItem.spec}</td>
								[#--<td>${cartItem.manufacturer}</td>--]
								<td>
									<span class='price'>${currency(cartItem.price)}</span>
								</td>
								<td class="cart-item-num">
									<div class="hp-stock">
										<a href="javascript:" class="cart-num-minus">-</a>
										<input type="text" value="${cartItem.quantity}" class='product-num'/>
										<a href="javascript:" class="cart-num-plus">+</a>
									</div>
								</td>
								<td>
									<span class='subtotal'>${currency(cartItem.subtotal)}</span>
									</td>
								<td><a href="javascript:" class="del-item">删除</a></td>
							</tr>
						[/#list]
					</form>


				</table>
                <div class="cart-toolbar float-bar">
                    <div class="selected-all fl">
                        <input id="selectedAll" type="checkbox" checked=true>
                        <label for="selectedAll">全选</label>
                    </div>
                    <div class="operation fl">
                        <a href="javascript:" id='deleteAll'>删除选中的商品</a>
                        <a href="javascript:batchCollect();">移到我的收藏</a>
                    </div>
                    <div class="toolbar-right fr">
                        <div class="amount-sum fl">
                            <span class="text">已选择</span><strong id='totalNumber'>0</strong><span class="text">件</span><i class="hide"></i>
                        </div>
                        <div class="price-sum fl">
                            <span class="text">合计(不含运费)：</span><strong><span>￥</span><span id='totalAmount'>0</span></strong>
                        </div>
                        <div class="btn-area fr">
                            <a href="javascript:" class="submit-btn">结算</a>
                        </div>
                    </div>
                    <div class="clear"></div>
                </div>
			[/#if]

			[#if cart.shopItems?has_content]
                <form  id="buyForm2" action="${base}/order/confirm2.jhtml" method="post">
				<table class="cart-main" style="margin-top:30px">
					<tr>
						<th width="40%">商品名称</th>
						<th width="8%">积分</th>
						<th width="10%">数量</th>
						<th width="8%">小计</th>
						<th width="10%">操作</th>
					</tr>

					[#list cart.shopItems as cartItem]
						<tr class="cart-list-item2" cart-item-id = ${cartItem.id}>
							<td>
								<table width="100%" class="cart-name-wrap">
									<tr>
										<td width="10%">
											<input type="checkbox" class="cartItemChecked2" goods-id="${cartItem.goodsId}" value="${cartItem.id}" name="cartItemIds" checked=true/>
										</td>
										<td width="15%" class="cart-item-img">
											<a href="${base}/intergral/content/${cartItem.goodsId}.jhtml" title="${cartItem.productName}" target="_blank">
												<img class="lazy" data-original="[@Pic pic=cartItem.image postfix='75x75'/]"  width="75" height="75" postfix="75x75">
											</a>
										</td>
										<td width="50%" class="cart-item-name">
											<a href="${base}/intergral/content/${cartItem.goodsId}.jhtml" target="_blank">
											${cartItem.productName}
											</a>
										</td>
									</tr>
								</table>
							</td>
						   [#-- <td>${cartItem.productCode}</td>
							<td>${cartItem.spec}</td>--]

							<td>
								<span class='price'>${cartItem.price}</span>
							</td>
							<td class="cart-item-num">
								<div class="hp-stock">
									<a href="javascript:" class="cart-num-minus">-</a>
									<input type="text" value="${cartItem.quantity}" class='product-num'/>
									<a href="javascript:" class="cart-num-plus">+</a>
								</div>
							</td>
							<td>
								<span class='subtotal'>${currency(cartItem.subtotal)}</span>
							</td>
							<td><a href="javascript:" class="del-item">删除</a></td>
						</tr>
					[/#list]
				</table>
                </form>
                <div class="cart-toolbar float-bar">
                    <div class="selected-all fl">
                        <input id="selectedAll" type="checkbox" checked=true>
                        <label for="selectedAll">全选</label>
                    </div>
                    <div class="operation fl">
                        <a href="javascript:" id='deleteAll'>删除选中的商品</a>
                    </div>
                    <div class="toolbar-right fr">
                        <div class="amount-sum fl">
                            <span class="text">已选择</span><strong id='totalNumber2'>0</strong><span class="text">件</span><i class="hide"></i>
                        </div>
                        <div class="price-sum fl">
                            <span class="text">合计(不含运费)：</span><strong><span></span><span id='totalAmount2'>0</span></strong>
                        </div>
                        <div class="btn-area fr">
                            <a href="javascript:" class="submit-btn2">积分结算</a>
                        </div>
                    </div>
                    <div class="clear"></div>
                </div>
			[/#if]

			[#else]
			<div class="cart-empty">
				<div class="message">
					<p>购物车空空如也，赶紧选购吧~~</p>
					<p><a href='/index.jhtml'>去购物></a></p>
				</div>
			</div>
			[/#if]
            <!--为您推荐-->
			[#include "common/recommand.ftl"]
        </div>
		[#include "common/footer-simple.ftl"]
		[#include "common/include_lazyload.ftl"]
	</body>
</html>